package com.simon.hse.activity.safe.workpermit;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.simon.hse.R;
import com.simon.hse.activity.BaseActivity;
import com.simon.hse.adapter.CommonEmptyAdapter;
import com.simon.hse.adapter.CommonViewHolder;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

/**
 * 作业许可证取消查询
 */
@SuppressWarnings("all")
@ContentView(R.layout.activity_work_permit_cancel_list)
public class WorkPermitCancelListlActivity extends BaseActivity {

    @ViewInject(R.id.tv_common_title)
    TextView mTv_common_title;

    @ViewInject(R.id.iv_common_right)
    ImageView mIv_common_right;

    @ViewInject(R.id.tv_function_1)
    TextView mTv_function_1;

    @ViewInject(R.id.tv_function_2)
    TextView mTv_function_2;

    @ViewInject(R.id.tv_function_3)
    TextView mTv_function_3;

    @ViewInject(R.id.common_swiperefreshlayout)
    SwipeRefreshLayout mSwipeRefreshLayout;

    @ViewInject(R.id.common_recyclerview)
    RecyclerView mRecyclerView;

    private int currentPage = 1, totalPage = 1;
    private CommonEmptyAdapter mCommonEmptyAdapter;
    private List<String> mDataBeanList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mTv_common_title.setText("作业许可证取消查询");
        mIv_common_right.setImageResource(R.mipmap.tab_add_icon);

        initRecyclerView();
        initData();
    }


    @Event(value = {R.id.iv_common_left, R.id.iv_common_right})
    private void clickButton(View view) {
        switch (view.getId()) {
            case R.id.iv_common_left:
                finish();
                break;
            case R.id.iv_common_right:
                Intent intent = new Intent(WorkPermitCancelListlActivity.this, WorkPermitApplyActivity.class);
                startActivity(intent);
                break;
        }
    }

    private void initRecyclerView() {
        LinearLayoutManager llm = new LinearLayoutManager(WorkPermitCancelListlActivity.this);
        mRecyclerView.setLayoutManager(llm);
        // 如果Item够简单，高度是确定的，打开FixSize将提高性能
        mRecyclerView.setHasFixedSize(true);
        // 设置Item默认动画，加也行，不加也行
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        mRecyclerView.setNestedScrollingEnabled(false);
        mCommonEmptyAdapter = new CommonEmptyAdapter(WorkPermitCancelListlActivity.this, R.layout.layout_item_work_permit_cancel, mDataBeanList);
        mCommonEmptyAdapter.setItemDatasListener(new CommonEmptyAdapter.ItemDatasListener<String>() {
            @Override
            public void setItemDatas(CommonViewHolder holder, String dataBean, int position) {
            }
        });

        mCommonEmptyAdapter.setOnItemClickListener(new CommonEmptyAdapter.OnItemClickListener() {
            @Override
            public void setOnItemClickListener(View view, int position) {
                Intent intent = new Intent(WorkPermitCancelListlActivity.this, WorkPermitDetailsActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("from", "applyCancel");
                intent.putExtras(bundle);
                startActivity(intent);
            }

            @Override
            public void setOnItemLongClickListener(View view, int position) {

            }
        });
        mRecyclerView.setAdapter(mCommonEmptyAdapter);
    }

    private void initData() {
        mTv_function_1.setText("状态");
        mTv_function_2.setText("工作单位");
        mTv_function_3.setText("申请时间");


        for (int i = 1; i < 2; i++) {
            mDataBeanList.add(i + "");
        }
        mCommonEmptyAdapter.notifyDataSetChanged();
    }
}
